range: Avoid rounding errors when allocating highlight
authorTimm Bäder <mail@baedert.org>
Sat, 15 Feb 2020 09:14:13 +0000 (10:14 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 15 Feb 2020 16:18:26 +0000 (17:18 +0100)
Fixes #2438

gtk/gtkrange.c

index 9feab541fce917ed8dd8fb35f176b13aedc5620b..9f54696a28c15331115b7b28b220669d02681efb 100644 (file)
@@ -1451,26 +1451,24 @@ gtk_range_allocate_trough (GtkGizmo *gizmo,
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
           highlight_alloc.y = 0;
+          highlight_alloc.width = MAX (min, value * width);
           highlight_alloc.height = height;
 
           if (!should_invert (range))
             highlight_alloc.x = 0;
           else
-            highlight_alloc.x = (width * (1 - value));
-
-          highlight_alloc.width = MAX (min, width * value);
+            highlight_alloc.x = width - highlight_alloc.width;
         }
       else
         {
           highlight_alloc.x = 0;
           highlight_alloc.width = width;
+          highlight_alloc.height = MAX (min, height * value);
 
           if (!should_invert (range))
             highlight_alloc.y = 0;
           else
-            highlight_alloc.y = (height * (1 - value));
-
-          highlight_alloc.height = MAX (min, height * value);
+            highlight_alloc.y = height - highlight_alloc.height;
         }
 
       gtk_widget_size_allocate (priv->highlight_widget, &highlight_alloc, -1);